package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.OrderStatus;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 分页查询预约信息
     * @param queryPageBean
     * @return
     */
    @PostMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        log.info("分页查询预约信息,{}",queryPageBean);
        return orderService.findPage(queryPageBean);
    }

    /**
     * 修改预约状态
     * @param orderStatus
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody OrderStatus orderStatus){
        log.info("修改预约状态,{}",orderStatus);
        orderService.updateStatus(orderStatus);
        return new Result(true, "修改预约状态成功");
    }
}
